//
//  MZCollectionReusableView.m
//  OurTourism
//
//  Created by 孟镇 on 15/11/25.
//  Copyright © 2015年 Devil_Coming. All rights reserved.
//

#import "MZCollectionReusableView.h"
#import "Header.h"

@interface MZCollectionReusableView ()

@property(nonatomic, strong) UILabel *titleLabel;
@property(nonatomic, strong) UIView *ornView;

@end

@implementation MZCollectionReusableView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        self.titleLabel = [[UILabel alloc] init];
        self.titleLabel.font = [UIFont fontWithName:@"KohinoorBangla-Regular" size:17];
        [self addSubview:self.titleLabel];
        
        self.ornView = [[UIView alloc] init];
        self.ornView.backgroundColor = [UIColor colorWithRed:62 / 255. green:176 / 255. blue:192 / 255. alpha:1];
        [self addSubview:self.ornView];
        
        self.moreBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [self addSubview:self.moreBtn];
        
    }
    return self;
}

- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes
{
    [super applyLayoutAttributes:layoutAttributes];
    self.titleLabel.frame = CGRectMake(30, 10, WIDTH, 30);
    self.ornView.frame = CGRectMake(10, 10, 10, 30);
    self.ornView.layer.cornerRadius = 7;
    
}

- (void)setIndex:(NSInteger)index {
    _index = index;
    if (_index == 2 || _index == 5 || _index == 6) {
        self.moreBtn.frame = CGRectMake(WIDTH - 40, 10, 30, 30);
        [self.moreBtn setImage:[UIImage imageNamed:@"iconfont-youjiantou@2x"] forState:UIControlStateNormal];
    }
    else {
        self.moreBtn.frame = CGRectMake(WIDTH - 40, 10, 0, 0);
    }
    
}

- (void)setTempModel:(MZRecommendModel *)tempModel
{
    _tempModel = tempModel;
    self.titleLabel.text = self.tempModel.title;
}


@end
